package org.eclipse.mylyn.rememberthemilk.ui;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.rememberthemilk.core.RTMCorePlugin;
import org.eclipse.mylyn.rememberthemilk.ui.wizards.RTMRepositorySettingsPage;
import org.eclipse.mylyn.rememberthemilk.ui.wizards.RtmCustomQueryPage;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;

public class RTMConnectorUi extends AbstractRepositoryConnectorUi {

	@Override
	public String getConnectorKind() {
		return RTMCorePlugin.REPOSITORY_KIND;
	}

	@Override
	public boolean hasSearchPage() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public IWizard getNewTaskWizard(TaskRepository repository, ITaskMapping selection) {
//		if (RtmRepositoryConnector.hasRichEditor(repository)) {
			return new NewTaskWizard(repository, selection);
//		}
	}

	@Override
	public IWizard getQueryWizard(TaskRepository taskRepository, IRepositoryQuery query) {
		// FIXME this won't work anymore
		// if (queryToEdit instanceof RTMRepositoryQuery) {
		// return new EditRtmQueryWizard(repository, query);
		// } else {
		// return new NewRtmQueryWizard(repository);
		// }
		// return new NewRtmQueryWizard(taskRepository, query);
		// return null;

		RepositoryQueryWizard wizard = new RepositoryQueryWizard(taskRepository);
		wizard.addPage(new RtmCustomQueryPage(taskRepository, "", query));
		return wizard;
	}

	@Override
	public ITaskRepositoryPage getSettingsPage(TaskRepository taskRepository) {
		return new RTMRepositorySettingsPage(taskRepository);
	}

}
